package com.app.budgetbook;

import java.util.Date;
import com.app.budgetbook.db.dbAdapter;
import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemSelectedListener;

public class MonthlyOverview extends Activity{
	
	protected Button ok;
	private dbAdapter dbHelper;
	private Cursor cursor;
	private TextView text;
	private Intent intent;
	 private Long mRowId;
	 private String month;
    
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.monthlyoverview);
		
		dbHelper = new dbAdapter(MonthlyOverview.this);
        dbHelper.open();
		
        Spinner spinner = (Spinner) findViewById(R.id.monthspinner);
        ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                this, R.array.month, android.R.layout.simple_spinner_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
        spinner.setOnItemSelectedListener(new MyOnItemSelectedListener());
        
        Button monthlyExpense = (Button)findViewById(R.id.mbutton1);
		monthlyExpense.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent intent = new Intent(MonthlyOverview.this, MonthlyCal.class);
			        intent.putExtra("month", month);
			       startActivity(intent); 
			       //Toast.makeText(parent.getContext(),  
			    	 //        "is Selected", Toast.LENGTH_LONG).show();
				//bClick.start();
			}
		});
        
      }
        
    

 class MyOnItemSelectedListener implements OnItemSelectedListener {

	public void onItemSelected(AdapterView<?> parent,
        View view, int pos, long id) {
    	
    	parent.getContext();
    	 month =parent.getItemAtPosition(pos).toString();
    	// Intent intent = new Intent(MonthlyOverview.this, MonthlyCal.class);
       // intent.putExtra("month", month);
       // startActivity(intent); 
    	
     // Toast.makeText(parent.getContext(),  
        //  parent.getItemAtPosition(pos).toString()+"is Selected", Toast.LENGTH_SHORT).show();

    
}

	@Override
	public void onNothingSelected(AdapterView<?> arg0) {
		// TODO Auto-generated method stub
		
	}
}
}